var fullLayer_max_zindex = 19891014;
var fullLayer_max_zindex2 = 20000822;
var fullLayer_min_zindex = 1040;
/**
 * 调入Js文件 nottryload 为真时不必调用，直接运行回调程序 nottryload 一般用于判断是否已加载某文件
 * 
 * @param js
 * @param callback
 * @returns
 */
function loadJs(js, callback, nottryload, ti)
{
	if (typeof js == 'function')
	{
		loadJs.afterLoadFun = js;
		loadJs.number = 0;
		loadJs.timer = setTimeout(function()
		{
			if (loadJs.afterLoadFun)
			{
				loadJs.afterLoadFun();
				loadJs.afterLoadFun = null;
			}
		}, 333);
		return;
	}
	// 版本，增加它可以强行加载文件
	var ver = '122';
	if (loadJs.isWebkit !== true && loadJs.isWebkit !== false)
	{
		// 检查是不是 webkit 内核，不是则拒绝加载，主要是避免兼容性
		var agent = navigator.userAgent || window.opera;
		if (!agent)
			loadJs.isWebkit = false;
		else
			loadJs.isWebkit = (agent.toLowerCase().indexOf('webkit') >= 0) ? true : false;
	}
	if (!loadJs.isWebkit)
	{
		layer.msg('请使用谷歌浏览器或以 webkit 为内核的浏览器以保证系统的兼容性。');
		loadJs.isWebkit = true;
	}
	if (nottryload)
	{
		if (typeof (callback) == 'function')
			callback();
		return;
	}
	if (js.indexOf('http:') === 0 || js.indexOf('https:') === 0)
		var src = js;
	else
		var src = 'static/' + js;
	// 看是不是已经调入，已经调入就不再调入，直接返回（执行回调程序）
	var sr = src.trim().toLowerCase();
	if (!loadJs.loadJsList)
		loadJs.loadJsList = {};
	var tt = loadJs.loadJsList[sr];
	if (tt)
	{
		ti = ti || 0;
		if (tt < 2 && ti < 32)
		{
			// 没有真正调入
			setTimeout(function()
			{
				loadJs(js, callback, nottryload, ti + 1);
			}, 100);
			return;
		}
		if (typeof (callback) == 'function')
			callback();
		return;
	}
	loadJs.loadJsList[sr] = 1;
	if (!loadJs.number)
		loadJs.number = 0;
	loadJs.number++;
	if (loadJs.timer)
		clearTimeout(loadJs.timer);
	if (!loadJs.ver)
		loadJs.ver = getCurVersion() + ver;
	var head = document.getElementsByTagName('head')[0];
	var script = document.createElement('script');
	script.src = src + '?r=' + loadJs.ver;
	script.type = 'text/javascript';
	script.onload = script.onreadystatechange = function()
	{
		loadJs.loadJsList[sr] = 2;
		if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")
		{
			script.onerror = script.onload = script.onreadystatechange = null;
			if (typeof (callback) == 'function')
				callback();
			loadJs.number--;
			if (loadJs.number <= 0 && loadJs.afterLoadFun)
			{
				if (loadJs.timer)
					clearTimeout(loadJs.timer);
				loadJs.timer = setTimeout(function()
				{
					loadJs.afterLoadFun();
					loadJs.afterLoadFun = null;
				}, 333);
			}
		}
	};
	script.onerror = function(err, dd)
	{
		script.onerror = script.onload = script.onreadystatechange = null;
		errorMsg('<p>load file<p>' + script.src + '<p> failed');
	}
	head.appendChild(script);
}
function loadCss(css, callback)
{
	if (css.indexOf('http:') === 0 || css.indexOf('https:') === 0)
		var src = css;
	else
		var src = 'static/' + css + '?r=' + loadJs.ver;
	var sr = src.trim().toLowerCase();
	if (!loadCss.loadCssList)
		loadCss.loadCssList = {};
	if (loadCss.loadCssList[sr])
	{
		if (typeof (callback) == 'function')
			callback();
		return;
	}
	loadCss.loadCssList[sr] = 1;
	var head = document.getElementsByTagName('head')[0];
	link = document.createElement("link");
	link.type = "text/css";
	link.rel = "stylesheet";
	link.href = src;
	link.onload = function()
	{
		link.onerror = link.onload = link.onreadystatechange = null;
		if (typeof (callback) == 'function')
			callback();
	}
	link.onerror = function(err, dd)
	{
		link.onerror = link.onload = link.onreadystatechange = null;
		errorMsg('<p>load file<p>' + link.href + '<p> failed');
	}
	head.appendChild(link);
}
/**
 * 取得图标代码
 * 
 * @param name
 * @param cla
 * @returns
 */
/*
 * function getIC(cla, tag, attr, text) { tag = tag || 'i'; cla = cla || 'fa-circle-o'; attr = attr || ''; text = text || ''; if ((' ' + cla).indexOf(' fa-') < 0) cla = 'fa-' + cla.trim(); return '<' + tag + ' ' + attr + ' class="fa ' + cla + '">' + text + '</' + tag + '>'; }
 */
function getIC(cla, tag, attr, text)
{
	tag = tag || 'i';
	cla = cla || 'fa-circle-o';
	attr = attr || '';
	text = text || '';
	var st = '';
	if ((' ' + cla).indexOf(' fa-') < 0)
		cla = 'fa-' + cla.trim();
	if (0 && app.vm && cla.indexOf('auto') > 0) // 暂时只用纯色
	{
		cla = ' ' + cla + ' ';
		cla = cla.replace(' yellow ', ' ');
		cla = cla.replace(' blue ', ' ');
		cla = cla.replace(' red ', ' ').trim();
		var s = '-abcdefghigklmnopqrstuvwxyz1234567890';
		var v = -999999999;
		var oldv = '';
		for (var i = 0; i < cla.length; i++)
		{
			var c = cla.substring(i, i + 1);
			oldv += c;
			var vi = s.indexOf(c);
			if (vi < 0)
			{
				oldv = '';
				if (v > 0)
					break;
				else
					continue;
			}
			if (oldv == 'fa-')
				v = 0;
			v += vi * i;
		}
		st = 'style="';
		var c = 128;
		if (cla.indexOf('autobcolor') > 0)
		{
			st += ';border-width:0;background-color:' + getIconColor(225, v);
			c = 80;
		}
		if (cla.indexOf('autobbcolor') > 0)
		{
			st += ';border-width:0;background-color:' + getIconColor(128, v);
			c = 225;
		}
		if (cla.indexOf('autocolor') > 0)
			st += ';color:' + getIconColor(c, v, true);
		st += '"';
	}
	return '<' + tag + ' ' + st + attr + ' class="fa ' + cla + '">' + text + '</' + tag + '>';
}
function getIconColor(h, v, isCos)
{
	if (!getIconColor.v)
		getIconColor.v = {};
	var k = v + (isCos ? '_' : '');
	if (getIconColor.v[k])
		return getIconColor.v[k];
	var rand = 1;
	if (isCos)
		v = Math.cos(v + rand);
	else
		v = Math.sin(v + rand);
	v = Math.floor(v * 256 * 256 * 256);
	var r = v % 256;
	var g = Math.floor(v / 256) % 256;
	var b = Math.floor(v / (256 * 256)) % 256;
	var hh = (r * 299 + g * 587 + b * 114) / 1000;
	if (hh > h)
	{
		var x = h / hh;
		r = Math.floor(r * x);
		g = Math.floor(g * x);
		b = Math.floor(b * x);
	}
	else if (hh < h)
	{
		var x = (255000 - h * 1000) / ((255 - r) * 299 + (255 - g) * 587 + (255 - b) * 114);
		r = Math.floor(255 - (255 - r) * x);
		g = Math.floor(255 - (255 - g) * x);
		b = Math.floor(255 - (255 - b) * x);
	}
	getIconColor.v[k] = 'rgb(' + r + ',' + g + ',' + b + ')';
	return getIconColor.v[k];
}
/**
 * 取得对象绝对位置和尺寸
 */
function getOffset(objLookingFor)
{
	if (!objLookingFor)
		return {};
	if (!objLookingFor.offsetParent)
	{
		var re = $(objLookingFor).offset();
		re.width = $(objLookingFor).width();
		re.height = $(objLookingFor).height();
		return re;
	}
	var posX = objLookingFor.offsetLeft;
	var posY = objLookingFor.offsetTop;
	var posW = $(objLookingFor).width();
	var posH = $(objLookingFor).height();
	var aBox = objLookingFor;
	do
	{
		aBox = aBox.offsetParent;
		if (!aBox)
			break;
		posX += aBox.offsetLeft - (aBox.scrollLeft || 0);
		posY += aBox.offsetTop - (aBox.scrollTop || 0);
	}
	while (aBox.tagName != "BODY");
	return {
		top : posY,
		left : posX,
		width : posW,
		height : posH
	}
}
/**
 * 关闭自己所在对话框
 * 
 * @param obj
 * @returns
 */
function closeSelfLayer(obj)
{
	var k = $(obj).parents('.layui-layer');
	if (k.length > 0)
	{
		var id = k[0].id + ' ';
		id = id.substring(11).trim();
		if (id)
			layer.close(id);
	}
}
function getAmountFromHtml(v)
{
	if (!v)
		return 0;
	v = (v + ' ').replace(/<[^>]+>/g, '').replace(/\,/g, '').trim();
	return parseFloat(v);
}
function isEmpty(obj)
{
	if (!obj)
		return true;
	for ( var key in obj)
	{
		return false;
	}
	return true;
}
/**
 * 取得合法的条形码 8 到 32 位，字母，数字，短线，下划线，括号，短线不能出现在第三个字符
 * 
 * @param v
 * @returns
 */
function validBarcode(v)
{
	v = (v + ' ').trim();
	if (v.indexOf(':ot:') > 0) // 后面可能带有效期
	{
		v = v.substring(0, v.indexOf(':ot:'));
	}
	if (!(/^[a-zA-Z0-9\-\_\(\)]{10,24}$/.test(v)))
		return '';
	if (/^[0-9]{2}\-/.test(v))
		return '';
	return v;
}
function getRandId(len)
{
	if (!len)
		len = 16;
	var k = 'abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789_';
	var c = '';
	var nn = k.length;
	for (var i = 0; i < len; i++)
	{
		var n = Math.floor(Math.random() * 128) % k.length;
		c += k.substring(n, n + 1);
	}
	return c;
}
/**
 * 取得一个伪随机数，要求在 minA,maxA 之间，n为随机种子，i为随机排序后的序号
 * 
 * @param minA
 * @param maxA
 * @param n
 * @param i
 * @returns
 */
function getRand(minA, maxA, n, i)
{
	if (minA == maxA)
		return maxA;
	else if (minA > maxA)
	{
		var v = minA;
		minA = maxA;
		maxA = v;
	}
	var len = maxA - minA + 1;
	var a = [];
	for (var k = minA; k <= maxA; k++)
		a.push(k);
	// 打乱顺序，实现a[0] 与任意一个进行交换
	for (var k = 1; k <= len * 2; k++)
	{
		var ri = Math.floor(Math.abs(Math.sin(a[0] + n + k) * 666666)) % len;
		var v = a[0];
		a[0] = a[ri];
		a[ri] = v;
	}
	len--;
	while (i < 0)
		i += len;
	while (i > len)
		i -= len;
	return a[i];
}
function strToInt(s)
{
	s = (s + ' ').trim();
	if (s.indexOf(':') > 0)
		s = s.substring(0, s.indexOf(':')).trim();
	s = parseInt(s);
	if (!s)
		s = 0;
	return s;
}
/**
 * 取得当前版本号 版本号在变量 cur_version 中，格式为 r=323-9089 , 其中 323 就是版本号，后面9089为随机数 版本号默认为1
 * 
 * @returns
 */
function getCurVersion(isMain, v)
{
	if (!v)
	{
		if (typeof cur_version != 'undefined')
			v = (cur_version + ' ').trim();
		else
			v = '';
	}
	if (v)
	{
		if (v.indexOf('=') >= 0)
		{
			v = v.substring(v.indexOf('=') + 1);
		}
		if (isMain)
		{
			var a = v.split('.');
			if (a.length >= 4)
			{
				v = '';
				for (var i = 0; i < 4; i++)
				{
					v += (i > 0 ? '.' : '') + a[i];
				}
			}
		}
		return v;
	}
	return '000.000.000.000';
}
/**
 * 取得当前时间（秒）
 * 
 * @returns
 */
function getTime()
{
	return Math.round((new Date()).getTime() / 1000);
}
/**
 * 返回几小时以前的时间
 * 
 * @returns
 */
function getTimeBeforeHour(n)
{
	return Math.round((new Date()).getTime() / 1000) - n * 3600;
}
/**
 * 取得形如 2019-12-31 的时间，用于初始化 input
 * 
 * @param cm
 *            cm==0 当月； cm==1 下月；d==0 今天 ；d==1 月初； d==2 月底； d==3 月底(月底未到则为今天)；
 * @param d
 * @returns
 */
function getDateStrForInput(cm, d, yearMonth)
{
	if (!cm)
		cm = 0;
	if (d != 1 && d != 2 && d != 3)
		d = 0;
	if (yearMonth > 0)
	{
		var y = Math.floor(yearMonth / 100);
		var m = yearMonth % 100 - 1 + cm;
	}
	else
	{
		var y = new Date().getFullYear();
		var m = new Date().getMonth() + cm;
	}
	if (d >= 2)
		m++;
	if (d == 0 || d == 1)
	{
		if (d == 0)
			d = new Date().getDate();
		return getDateStr(new Date(y, m, d).getTime(), false, false, true);
	}
	else
	{
		var now = new Date().getTime();
		var t = new Date(y, m, 1).getTime() - 3600 * 12;
		if (d == 3 && now > new Date(y, m - 1, 1).getTime() && now < t)
			t = now;
		return getDateStr(t, false, false, true);
	}
}
function getSimpleDateStr(t)
{
	if (!t || t < 3600 * 24 * 365 || t == '0')
		return '';
	t = parseInt((t + ' ').trim());
	if (!t)
		return '';
	if (/^\d{13,14}\.{0,1}\d{0,16}$/.test(t)) // 毫秒
	{
		var dt = getTime() - t / 1000;
		var t = new Date(parseInt(t));
	}
	else if (/^\d{8,11}\.{0,1}\d{0,16}$/.test(t))
	{
		var dt = getTime() - t;
		var t = new Date(parseInt(t) * 1000);
	}
	else
	{
		return '';
	}
	var t0 = new Date();
	if (t.getFullYear() != t0.getFullYear() && dt > 3600 * 24 * 62)
		return t.getFullYear() + app.w('year').trim();
	else if ((t.getFullYear() == t0.getFullYear() && t.getMonth() == t0.getMonth() && t.getDate() == t0.getDate()) || dt < 3600 * 48)
	{
		var pr = '';
		if (Math.abs(t0.getDate() - t.getDate()) > 1)
			pr = app.w('beforeYesterday').trim() + ' ';
		else if (Math.abs(t0.getDate() - t.getDate()) > 0)
			pr = app.w('yesteray').trim() + ' ';
		var h = t.getHours();
		if (h < 10)
			h = '0' + h;
		var m = t.getMinutes();
		if (m < 10)
			m = '0' + m;
		return pr + h + ':' + m;
	}
	else
	{
		return (t.getMonth() + 1) + app.w('month').trim() + t.getDate() + app.w('day').trim();
	}
}
// 取得时间长度
function getDateLength(t)
{
	if (!t || t <= 0)
		return '';
	var s = t % 60;
	var m = Math.floor(t / 60) % 60;
	var h = Math.floor(t / 3600) % 24;
	var d = Math.floor(t / (3600 * 24));
	var r = '';
	if (d > 0)
		r += d + app.w('day').trim();
	if (h > 0 || d > 0)
		r += h + app.w('hour').trim();
	if (m > 0 || h > 0 || d > 0)
		r += m + app.w('minute').trim();
	r += s + app.w('second').trim();
	return r;
}
/**
 * 格式化时间
 * 
 * @param t
 * @param havtime
 * @returns
 */
function getDateStr(t, havtime, justtime, isfull, isAgo)
{
	if (!t || t < 3600 * 24 || t == '0')
		return '';
	t = (t + ' ').trim();
	if (/^\d{13,14}\.{0,1}\d{0,16}$/.test(t)) // 毫秒
		var t = new Date(parseInt(t));
	else if (/^\d{8,11}\.{0,1}\d{0,16}$/.test(t))
		var t = new Date(parseInt(t) * 1000);
	else
	{
		if (isAgo)
			return '';
		return t;
	}
	if (isAgo)
	{
		var dt = Math.round((new Date().getTime() - t.getTime()) / 1000);
		if (dt < 0 && dt > -60)
			dt = 0
		if (dt >= 0)
		{
			if (dt < 3)
				return app.w('thisTime').trim();
			if (dt < 60)
				return dt + app.w('secondAgo').trim();
			else if (dt < 3600)
				return Math.round(dt / 60) + app.w('minuteAgo').trim();
			else if (dt < 3600 * 4)
				return Math.round(dt / 3600) + app.w('hourAgo').trim();
		}
	}
	var m = t.getMonth() + 1;
	if (m < 10)
		m = '0' + m;
	var d = t.getDate();
	if (d < 10)
		d = '0' + d;
	var s = '';
	if (!justtime)
	{
		if (isfull || t.getFullYear() != (new Date()).getFullYear())
			s += t.getFullYear() + '-';
		if (havtime && !isfull && t.getFullYear() == (new Date()).getFullYear() && t.getMonth() == (new Date()).getMonth() && t.getDate() == (new Date()).getDate())
			s = '';
		else
			s += m + '-' + d;
	}
	if (havtime)
	{
		var h = t.getHours();
		if (h < 10)
			h = '0' + h;
		var m = t.getMinutes();
		if (m < 10)
			m = '0' + m;
		var e = t.getSeconds();
		if (e < 10)
			e = '0' + e;
		s += ' ' + h + ':' + m
		if (isfull)
			s += ':' + e;
	}
	return s.trim();
}
/**
 * 全屏编辑，backfun返回false，则表示错误，不能关闭窗口
 * 
 * @param str
 * @param backfun
 * @returns
 */
function fullEdit(str, backfun, testfun, caption)
{
	if (!str)
		str = "";
	else
		str = str.replace(/[\r]/g, '').replace(/\n{3,16}/g, '\n\n').replace(/(\s*$)/g, "");
	if (fullEdit.layerIndex)
	{
		layer.close(fullEdit.layerIndex);
		fullEdit.layerIndex = 0;
		fullEdit(str, backfun, testfun, caption);
		return;
	}
	var html = '<textarea id="fullEdit_con" style="color:#fff;background-color:#000;font-size:14px;display:block;margin:0 auto;margin-top:12px;width:98%;white-space: nowrap;"></textarea>';
	html += '<div class="box-footer">'
	html += '<button class="btn btn-info pull-right submit"  onclick="fullEdit.submit()">' + app.w('submit') + '</button>';
	html += '<button class="btn btn-info pull-right submit" style="margin-right:12px" onclick="layer.close(fullEdit.layerIndex)">' + app.w('cancel') + '</button> ';
	html += '<button class="btn btn-info pull-right submit" style="margin-right:12px" onclick="fullEdit.lineNo()">' + app.w('lineNo') + '</button> ';
	if (testfun)
		html += '<button class="btn btn-info pull-right submit" style="margin-right:12px" onclick="fullEdit.testfun()">' + app.w('test') + '</button> ';
	html += '</div>';
	fullEdit.layerIndex = showFullLayer(caption ? caption : app.w('edit'), html, function()
	{
		fullEdit.layerIndex = null
	}, false, 0.2);
	setTimeout(function()
	{
		$('#fullEdit_con').val(str);
		var h = $('#fullEdit_con').parent().height() - 80;
		$('#fullEdit_con').animate({
			height : h
		}, 500);
	}, 100);
	fullEdit.testfun = function()
	{
		if (testfun)
		{
			var con = $('#fullEdit_con').val();
			testfun(addLineNo(con, true), function(newcon)
			{
				if (typeof newcon == 'string')
					$('#fullEdit_con').val(newcon);
			});
		}
	}
	fullEdit.lineNo = function()
	{
		var con = $('#fullEdit_con').val();
		$('#fullEdit_con').val(addLineNo(con, con.indexOf(":0001:") === 0));
	}
	fullEdit.submit = function()
	{
		var con = addLineNo($('#fullEdit_con').val(), true);
		backfun(con, function(isok)
		{
			if (isok !== false)
				layer.close(fullEdit.layerIndex);
		});
	};
	function addLineNo(con, isremove)
	{
		con = con.replace(/\n\:\d\d\d\d\:[\s]{0,2}/g, "\n");
		con = con.replace(/^\:\d\d\d\d\:[\s]{0,2}/g, "");
		if (isremove)
		{
			return con;
		}
		else
		{
			var a = (con + ' ').split("\n");
			var str = '';
			for (var i = 0; i < a.length; i++)
			{
				var ii = i + 1;
				if (ii < 10)
					ii = '000' + ii;
				else if (ii < 100)
					ii = '00' + ii;
				else if (ii < 1000)
					ii = '0' + ii;
				str += ':' + ii + ':  ' + a[i] + "\n";
			}
			return str;
		}
	}
}
function fullEditArray(backfun, str, checkFirst)
{
	if (str && !checkFirst)
	{
		ajax.request('wtp.login.tools.getArrayFromString', {
			string : str
		}, function(d, ad)
		{
			if (ad.arr)
				fullEditArray(backfun, (new formFun).getTextFromArray(ad.arr), true);
			else
				fullEditArray(backfun, str, true);
		}, function(msg, msg2)
		{
			errorMsg(msg2);
			fullEditArray(backfun, str, true);
		});
		return;
	}
	fullEdit(str, function(str, okfun)
	{
		if (!str)
		{
			backfun('');
			okfun(true);
			return;
		}
		ajax.request('wtp.login.tools.getArrayFromString', {
			string : str
		}, function(d, ad)
		{
			if (!ad.arr)
				ad.arr = {};
			backfun((new formFun).getTextFromArray(ad.arr));
			okfun(true);
		});
	}, function(str, okfun)
	{
		if (!str)
		{
			return backfun('');
		}
		ajax.request('wtp.login.tools.GetArrayFromString', {
			string : str
		}, function(d, ad)
		{
			if (ad.arr)
			{
				okfun((new formFun).getTextFromArray(ad.arr));
			}
		});
	});
}
/**
 * 格式化金额
 * 
 * @param nums
 * @returns
 */
function formatAmount(nums, emptyIfZero)
{
	if (nums === null)
		return emptyIfZero ? '' : 'null';
	if (typeof (nums) == 'string')
	{
		nums = nums.replace(/\,/g, '');
		var num = parseFloat(nums);
	}
	else
		var num = nums;
	if (isNaN(num))
		return nums;
	else if (emptyIfZero && num == 0)
		return '';
	var parts = num.toFixed(2).toString().split(".");
	parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
	var re = parts.join(".");
	if ((re + ' ').indexOf('-') == 0)
		re = ('<font class="red">' + re + '</font>').replace('-', '');
	return re;
}
/**
 * 是否处于顶层
 * 
 * @param index
 * @returns
 */
function isTopFullLayer(index)
{
	if (showFullLayer.index && showFullLayer.index.length > 0 && showFullLayer.index[showFullLayer.index.length - 1].id == index)
		return true;
	else
		return false;
}
/**
 * 关闭所有的全面屏
 * 
 * @returns
 */
function closeFullLayer(afterms, notColseTop, justOne, ii)
{
	if (ii === undefined)
	{
		if (!showFullLayer.index || showFullLayer.index.length == 0)
			return false;
		if (afterms > 0)
		{
			setTimeout(function()
			{
				closeFullLayer(0, true, justOne)
			}, afterms);
			return;
		}
		ii = showFullLayer.index.length - 1;
	}
	if (ii < 0)
		return;
	if (notColseTop && ii == showFullLayer.index.length - 1)
	{
		closeFullLayer(0, 0, justOne, ii - 1);
	}
	closeFullLayerOne(showFullLayer.index[ii].id, function()
	{
		if (!justOne)
			closeFullLayer(0, 0, 0, ii - 1);
	});
}
/**
 * 关闭一个全面屏， 回调函数返回false，表示没有成功关闭
 * 
 * @param layerIndex
 * @param sipOkToChangeMain
 * @returns
 */
function closeFullLayerOne(layerIndex, backfun, sipOkToChangeMain)
{
	if ($('.fulllayer#layui-layer' + layerIndex).length <= 0)
	{
		layer.close(layerIndex);
		if (backfun)
			backfun(true);
		return;
	}
	// 关闭前确认
	if (!sipOkToChangeMain)
	{
		if (!left.okToChangeMain(null, layerIndex))
		{
			left.okToChangeMain(function()
			{
				closeFullLayerOne(layerIndex, backfun, true);
			}, layerIndex);
			return;
		}
	}
	var d1 = '#layui-layer' + layerIndex;
	var k = $(d1);
	// 寻找 i(存储序号)
	var i = -1;
	if (showFullLayer.index && showFullLayer.index.length > 0)
	{
		for (var ii = showFullLayer.index.length - 1; ii >= 0; ii--)
		{
			if (showFullLayer.index[ii].id == layerIndex)
			{
				i = ii;
				break;
			}
		}
	}
	// 询问是否可以关闭
	if (i >= 0 && showFullLayer.index[i].functions && showFullLayer.index[i].functions.onQueryClose)
	{
		var queryClose = showFullLayer.index[i].functions.onQueryClose;
		queryClose(function(re)
		{
			if (re !== false)
			{
				showFullLayer.index[i].functions.onQueryClose = null;
				closeFullLayerOne(layerIndex, backfun, true);
			}
		});
		return;
	}
	// 以下是关闭
	if (app.vm && i >= 0)
	{
		if (k.length > 0)
		{
			if (i > 0)
			{
				var la = showFullLayer.index[i - 1].id;
				var d2 = '#layui-layer' + la;
			}
			else
				var d2 = '#maincontent';
			moveFullLayer(false, d1, d2, function()
			{
				k.hide();
				layer.close(layerIndex);
			});
		}
	}
	else
	{
		layer.close(layerIndex);
	}
	if (backfun)
		backfun(true);
}
function getFullLayerNumber(afterms, notColseTop, justOne)
{
	if (showFullLayer.index || showFullLayer.index.length > 0)
		return showFullLayer.index.length;
	return 0;
}
function getWindowHeight()
{
	var h = $(window).height();
	if ($(window).width() < 600)
	{
		if (!app || !app.isSinglePage())
			h -= 40;
	}
	return h;
}
function getFullArea(isrealfull, haveleft)
{
	var obj = $('#maincontent')[0];
	if (!obj)
		return null;
	var l = 0;
	var w = obj.offsetWidth || $('body').width();
	var t = 0;
	var wh = $(window).height();
	if (isrealfull)
	{
		w = $('body').width();
		var h = wh - t;
	}
	else if (app.vm || wh < 720)
	{
		var h = getWindowHeight() - t;
	}
	else
	{
		for (t = obj.offsetTop, l = obj.offsetLeft; obj = obj.offsetParent;)
		{
			t += obj.offsetTop;
		}
		t += 0 - $(document).scrollTop();
		if (t < 0)
			t = 0;
		var h = app.getMainHeight() + 111 - t;
		if (left.isTopHeadNav())
			h -= 45;
		if (left.hideTop())
			h += 40;
	}
	return {
		w : w,
		h : h,
		l : l,
		t : t
	};
	// //////////////////////////////
	// 以下将作废
	var obj = $('#maincontent')[0];
	if (!obj)
		return null;
	var l = 0;
	var w = obj.offsetWidth || $('body').width();
	var t = 0;
	if (isrealfull)
	{
		w = $('body').width();
		var h = $('body').height() - t;
	}
	else if (app.vm)
	{
		var h = getWindowHeight() - t;
	}
	else
	{
		w -= 31;
		for (t = obj.offsetTop, l = obj.offsetLeft; obj = obj.offsetParent;)
		{
			t += obj.offsetTop;
			l += obj.offsetLeft;
		}
		t += 15 - $(document).scrollTop();
		if (t < 0)
			t = 0;
		l += 16;
		var h = app.getMainHeight() + 120 - t;
		if (left.isTopHeadNav())
			h -= 45;
	}
	if (!app.vm && haveleft === true && l < 150)
	{
		l += 300;
		w -= 300;
	}
	else if (!app.vm && haveleft === false && l > 150)
	{
		l -= 300;
		w += 300;
	}
	return {
		w : w,
		h : h,
		l : l,
		t : t
	};
}
function resizeFullLayer(haveleft, ms)
{
	if (ms > 0)
	{
		if (resizeFullLayer.resizetimer)
			clearTimeout(resizeFullLayer.resizetimer);
		resizeFullLayer.resizetimer = setTimeout(function()
		{
			resizeFullLayer(haveleft, 0);
			resizeFullLayer.resizetimer = 0
		}, ms);
		return;
	}
	var p = getFullArea(true, haveleft);
	if ($('.realfull').length > 0)
	{
		$('.realfull').css('top', p.t + 'px');
		$('.realfull').css('left', p.l + 'px');
		$('.realfull').css('width', p.w + 'px');
		$('.realfull').css('height', p.h + 'px');
	}
	if ($('.leftfull').length > 0)
	{
		var p = getFullArea(false, haveleft);
		$('.leftfull').css('top', p.t + 'px');
		$('.leftfull').css('left', p.l + 'px');
		$('.leftfull').css('width', p.w + 'px');
		$('.leftfull').css('height', p.h + 'px');
		$('.leftfull .layui-layer-content').css('height', (p.h - 45) + 'px');
	}
	// 改变zIndex
	$('.fulllayer').each(function()
	{
		var zIndex = parseInt($(this).css('z-index'));
		if (!zIndex)
			zIndex = fullLayer_min_zindex;
		isAbstop = ($(this).hasClass('abstop') || p.t <= 0);
		if (isAbstop && zIndex < fullLayer_max_zindex)
			$(this).css('z-index', zIndex + fullLayer_max_zindex - fullLayer_min_zindex);
		else if (!isAbstop && zIndex >= fullLayer_max_zindex)
			$(this).css('z-index', zIndex - fullLayer_max_zindex + fullLayer_min_zindex);
	});
	// 改变菜单按钮位置
	var k = $('.fulllayerrightmenu');
	if (k.length > 0)
	{
		var maxWidth = parseInt(k.attr('maxWidth')) || 0;
		if (maxWidth > 0 && !app.vm && p.w > maxWidth)
			var w = p.w - (p.w - maxWidth) / 2 - 40;
		else
			var w = p.w - (app.vm ? 40 : 80);
		k.css('left', w + 'px');
	}
	if (showFullLayer.index)
	{
		for (var i = showFullLayer.index.length - 1; i >= 0; i--)
		{
			if (showFullLayer.index[i].functions)
			{
				var fun = showFullLayer.index[i].functions;
				if (fun.onReSize)
					fun.onReSize();
			}
		}
	}
}
/**
 * 全屏显示一个layer
 * 
 * @param caption
 * @param html
 * @param endFun
 * @param isrealfull
 * @param shade
 * @param skin
 * @param scrollhidden
 * @param onshowfun
 * @param rightmenu
 * @param maxWidth
 * @param functions
 *            包含函数 onShow onActive onUnActive onUnShow onClose onQueryClose 等函数（也是它们的执行顺序）
 * @param delayms
 *            延迟显示内容
 * @returns
 */
function showFullLayer(caption, html, endFun, isrealfull, shade, skin, scrollhidden, onActiveFun, rightmenu, maxWidth, functions, delayms)
{
	if (!skin)
		skin = '';
	if (showFullLayer.classname)
	{
		skin += ' ' + showFullLayer.classname;
		showFullLayer.classname = '';
	}
	if (onActiveFun)
	{
		if (!functions)
			functions = {};
		functions.onActive = onActiveFun;
	}
	var p = getFullArea(isrealfull);
	if (p.t <= 16)
		skin += ' topfull';
	var title = '<span>' + caption + '</span><div class="layerbtn layer_close fa ' + (app.vm ? 'fa-arrow-left' : 'fa-close') + '"></div>';
	if (!app.vm && p.t <= 0)
	{
		title += '<img style="position:absolute;width:36px;height:36px;left:6px;top:2px" class="logo" src="static/' + app.core + '/skin/simple/images/logo.png">';
	}
	if (!html)
		html = '';
	if (maxWidth > 0 && maxWidth < $(window).width() - 80)
		html = '<div style="max-width:' + maxWidth + 'px;margin:0 auto">' + html + '</div>';
	else
		maxWidth = 0;
	var rightmenuId = '';
	if (rightmenu)
	{
		rightmenuId = getRandId();
		if (!left.fulllayerrightmenu)
			left.fulllayerrightmenu = {};
		left.fulllayerrightmenu[rightmenuId] = rightmenu;
		var faa = app.vm ? 'fa-th s20' : 'fa-th pointer';
		if (maxWidth > 0 && !app.vm && p.w > maxWidth)
			var w = p.w - (p.w - maxWidth) / 2 - 40;
		else
			var w = p.w - (app.vm ? 40 : 80);
		title += '<div maxWidth="' + maxWidth + '" class="layerbtn fulllayerrightmenu" id="' + rightmenuId + '" style="left:' + w + 'px;"><i class="fa ' + faa + '"></i></div>';
	}
	var anim = app.vm && !isrealfull;
	var para = {
		type : 1,
		skin : 'nav-tabs-custom fulllayer' + (app.vm ? ' mlayer ' : '') + (isrealfull ? ' realfull' : ' leftfull') + (skin ? (' ' + skin) : '') + (scrollhidden ? ' scrollhidden' : ''),
		title : title,
		content : delayms && anim ? '' : html,
		shade : !app.vm && shade ? shade : 0,
		anim : -1,
		isOutAnim : false,
		closeBtn : false,
		resize : false,
		move : false,
		end : function()
		{
			left.setReturnFun(false, para.layerIndex);
			if (showFullLayer.index)
			{
				var thisIsTop = false;
				for (var i = showFullLayer.index.length - 1; i >= 0; i--)
				{
					if (showFullLayer.index[i].id == para.layerIndex)
					{
						if (i == showFullLayer.index.length - 1)
							thisIsTop = true;
						if (showFullLayer.index[i].functions)
						{
							var fun = showFullLayer.index[i].functions;
							if (fun.onUnActive)
								fun.onUnActive();
							if (fun.onUnShow)
								fun.onUnShow();
							if (fun.onClose)
								fun.onClose();
						}
						showFullLayer.index.splice(i, 1);
						break;
					}
				}
				// 顶层关闭，执行下层的active函数
				if (thisIsTop && showFullLayer.index.length > 0)
				{
					if (showFullLayer.index[showFullLayer.index.length - 1].functions)
					{
						var fun = showFullLayer.index[showFullLayer.index.length - 1].functions;
						if (fun.onActive)
							fun.onActive();
					}
				}
				else if (showFullLayer.index.length == 0)
				{
					if (left.maincontent.onActiveFun)
						left.maincontent.onActiveFun();
					if (!app.vm)
					{
						$('#maincontent span.righttopclose').removeClass('hidden');
						$('body').removeClass('infulllayer');
					}
				}
			}
			if (rightmenuId)
				delete left.fulllayerrightmenu[rightmenuId];
			if (endFun)
				endFun();
		},
		zIndex : ((skin && skin.indexOf('abstop') >= 0) || p.t <= 0) ? fullLayer_max_zindex : fullLayer_min_zindex,
	};
	para['offset'] = [ p.t, p.l == 0 ? 0.00001 : p.l ];
	para['area'] = [ p.w + 'px', p.h + 'px' ];
	if (!app.vm)
	{
		$('body').addClass('infulllayer');
	}
	var layerIndex = layer.open(para);
	if (anim)
	{
		if (showFullLayer.index && showFullLayer.index.length > 0)
			var d1 = '#layui-layer' + showFullLayer.index[showFullLayer.index.length - 1].id;
		else
			var d1 = '#maincontent';
		var d2 = '#layui-layer' + layerIndex;
		moveFullLayer(true, d1, d2, function()
		{
			if (delayms)
			{
				$('#layui-layer' + layerIndex + ' .layui-layer-content').html(html);
			}
		});
	}
	para.layerIndex = layerIndex;
	if (!showFullLayer.index)
		showFullLayer.index = [];
	if (showFullLayer.index.length > 0)
	{
		var oldFunctions = showFullLayer.index[showFullLayer.index.length - 1].functions;
		if (oldFunctions && oldFunctions.onUnActive)
			oldFunctions.onUnActive();
	}
	showFullLayer.index.push({
		id : layerIndex,
		functions : functions,
		isrealfull : isrealfull ? 1 : 0
	});
	if (functions)
	{
		if (functions.onShow)
			functions.onShow();
		setTimeout(function()
		{
			if (functions.onActive)
				functions.onActive();
		}, 333);
	}
	return layerIndex;
}
/*
 * 移出移入动画
 */
function moveFullLayer(toLeft, d1, d2, backfun)
{
	var time = 200; // 动画时间，比css定义的稍短
	app.lockScreen(time);
	setTimeout(function()
	{
		if (backfun)
			backfun();
		if (toLeft)
		{
			$(d1).removeClass('fromcentertoleft');
			$(d2).removeClass('fromrighttocenter');
		}
		else
		{
			$(d1).removeClass('fromcentertoright');
			$(d2).removeClass('fromlefttocenter');
		}
	}, time);
	if (toLeft)
	{
		$(d1).addClass('fromcentertoleft');
		$(d2).addClass('fromrighttocenter');
	}
	else
	{
		$(d1).addClass('fromcentertoright');
		$(d2).addClass('fromlefttocenter');
	}
}
/**
 * 显示一个提交框
 * 
 * @param caption
 * @param form
 * @param backfun
 * @param w
 * @param h
 * @returns
 */
function showForm(caption, form, backfun, w, h, endfun, skin)
{
	var layerIndex = null;
	var para = {
		type : 1,
		skin : 'layui-layer-rim' + (skin ? (' ' + skin) : ''),
		area : [ w + 'px', h + 'px' ],
		title : caption,
		content : form.html,
		anim : -1,
		isOutAnim : false,
		end : function()
		{
			if (endfun)
				endfun();
		}
	};
	if (skin && skin.indexOf('abstop') >= 0)
		para['zIndex'] = fullLayer_max_zindex2;
	layerIndex = layer.open(para);
	form.options.requestBackFun = function()
	{
		if (backfun)
			backfun();
		else
			layer.msg(app.w('optionOk'));
	};
	return layerIndex;
}
/**
 * 显示一个信息
 * 
 * @param caption
 * @param msg
 * @param w
 * @returns
 */
function showList(caption, html, area, endfun, height, width)
{
	if (!height)
		height = 460;
	else if (height < 160)
		height = 160;
	else if (height > 600 && app.vm)
		height = $(window).height();
	else if (height > getWindowHeight())
		height = getWindowHeight();
	if (!width)
		width = 320;
	if (app.vm || width > $(window).width())
		width = $(window).width();
	var para = {
		type : 1,
		title : caption + (app.vm ? '<div class="layerbtn layer_close fa fa-arrow-left"></div>' : ''),
		skin : 'showlist' + (app.vm ? ' mlayer' : ''),
		area : (area ? area : [ width + 'px', height + 'px' ]),
		content : html,
		move : !app.vm,
		anim : -1,
		isOutAnim : false,
		end : function()
		{
			if (endfun)
				endfun();
		},
	};
	if ($('.abstop').length > 0)
		para.zIndex = fullLayer_max_zindex2;
	return layer.open(para);
}
/**
 * 显示列表以供选择，并回调 backfun(id,name)
 * 
 * @param caption
 * @param arr
 *            {id1:name1,id2:name2}
 * @param backfun
 * @returns
 */
function selectList(caption, arr, backfun, classname, endfun, allowInput, noClear, mulSelect, tophtml, mulOnce)
{
	var that = this;
	var table = null;
	var layerIndex = null;
	tophtml = tophtml || null;
	if (backfun)
	{
		tophtml = tophtml || {};
		if (allowInput)
		{
			tophtml['cmd88'] = {
				'issearch' : true,
				'placeholder' : app.w('inputvalue'), // 为搜索时，这是提示语句
				'caption' : '',// 标题
				'icon' : 'fa-edit', // 图标
				'fun' : function(wd)
				{
					if (wd)
					{
						backfun(wd, '', []);
						layer.close(layerIndex);
					}
				}
			};
		}
		if (!noClear)
		{
			tophtml['cmd99'] = {
				caption : app.w('clear'),
				icon : 'fa-eraser',
				fun : function(fun)
				{
					backfun('', '', [])
					layer.close(layerIndex);
				}
			};
		}
	}
	table = new tableFun({
		container : '',
		showheader : false,
		classname : (backfun ? '' : 'tablelist') + (classname ? (' ' + classname) : ''),
		refreshbtn : false,
		tophtml : tophtml,
		loadDataFun : function(page, fun)
		{
			var d = [];
			for ( var id in arr)
			{
				if (typeof arr[id] == 'object')
					var name = formatData(JSON.stringify(arr[id]), 'jsoninline');
				else
					var name = arr[id];
				d.push({
					id : id,
					name : name,
					data : arr[id]
				})
			}
			fun(d);
		},
		clickTrFun : !backfun ? null : function(index, idi, data)
		{
			if (false === backfun(idi, data['name'], data['data']))
				return;
			layer.close(layerIndex);
		},
		hideoption : true,
		'header' : {
			_mu_ : mulSelect,
			id : '',
			data : '',
			name : 'name',
			_op_ : [ {
				title : app.w('select'),
				icon : 'fa-check',
				_mu_ : true,
				hideop : true,
				muonce : mulOnce,
				fun : function(index, idi, data, isLast)
				{
					if (typeof idi == 'object')
					{
						isLast = true;
						var name = [];
						var da = [];
						for (var i = 0; i < data.length; i++)
						{
							name.push(data[i].name);
							da.push(data[i].data);
						}
						backfun(idi, name, da, isLast);
					}
					else
						backfun(idi, data['name'], data['data'], isLast);
					if (isLast)
						layer.close(layerIndex);
				}
			} ]
		}
	});
	var i = 0;
	for ( var id in arr)
	{
		i++;
	}
	var he = i <= 0 ? 240 : (i * table.getTdHeight() + 105);
	if (he > $(window).height() - 12)
		he = $(window).height() - 12;
	layerIndex = showList(caption || ' ', table.html, null, endfun, he);
	return layerIndex;
}
/**
 * 显示错误信息
 * 
 * @param msg
 * @param caption
 * @param endfun
 * @returns
 */
function errorMsg(msg, caption, endfun, cla, noBtn)
{
	if (!caption)
		caption = app.w('error');
	return _showInnerMsg(caption, msg, 0, endfun, 2, '', false, false, false, cla, 0, noBtn);
}
/**
 * 显示信息
 * 
 * @param caption
 * @param msg
 * @param w
 * @param endfun
 * @param icon
 * @param btntitle
 * @returns
 */
function showMsg(caption, msg, w, endfun, icon, btntitle, notToHtml, notadd, btn2, cla, h, noBtn)
{
	if (icon == undefined || icon == null)
		icon = 0;
	return _showInnerMsg(caption, msg, w, endfun, icon, btntitle, notToHtml, notadd, btn2, cla, h, noBtn);
}
function closeAllInnerMsg()
{
	$('.layui-layer.innerMsg').each(function()
	{
		var id = $(this)[0].id;
		if (id && id.indexOf('layui-layer') === 0)
		{
			id = parseInt(id.substring(11));
			layer.close(id);
		}
	});
}
function _showInnerMsg(caption, msg, w, endfun, icon, btntitle, notToHtml, notadd, btn2, cla, h, noBtn)
{
	// 该参数暂时强制为真
	notadd = true;
	if (window.left && left.isShowFace())
	{
		if (!caption)
			caption = '';
		if (!msg)
			msg = '';
		if (endfun)
			endfun();
		return layer.msg(caption + ' : <p>' + msg, {
			icon : icon || 7,
			time : 5000
		});
	}
	cla = cla || '';
	if (!_showInnerMsg.m)
		_showInnerMsg.m = {};
	if (!msg)
	{
		var m = caption;
		var t = app.w('info');
	}
	else
	{
		var m = msg;
		var t = caption || app.w('info');
	}
	if (m.length > 2048 && !notToHtml)
	{
		return showHtml('<strong>' + t + '</strong><br><br>' + m, true);
	}
	if (!w)
	{
		if (m.length < 32)
		{
			m = '<p style="margin-top:12px">' + m;
			w = 258;
		}
		else
		{
			w = app.vm ? $(window).width() : (m.length < 200 ? 320 : (m.length < 2048 ? 600 : $(window).width()));
		}
	}
	if (w >= $(window).width())
		w = $(window).width();
	if (h >= $(window).height())
		h = $(window).height();
	if (w >= $(window).width() && h >= $(window).height())
	{
		cla += ' realfulllayer';
	}
	if (icon > 0)
		m = '<i class="layui-layer-ico layui-layer-ico' + icon + '"></i> &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp; ' + m;
	else
		icon = 0;
	var id = '_thisshowmsg_' + icon;
	var con = $('#' + id);
	if (con.length > 0 && _showInnerMsg.m[id] && !notadd)
	{
		m = _showInnerMsg.m[id] + '<div style="padding-top:3px;margin-top:3px;border-top:1px dotted #b92d22">' + m.replace(/\<br\>\<br\>/g, '<br>') + '</div>';
		$('#' + id).html(m);
		var minheight = Math.min(getWindowHeight() - 98, 400);
		$('.' + id + ' .layui-layer-content').css('min-height', minheight + 'px');
		_setInnerMsgTop(id);
		_showInnerMsg.m[id] = m;
		return;
	}
	if (!notadd)
		_showInnerMsg.m[id] = m;
	var layerrindex = 0;
	var p = {
		type : 1,
		skin : 'layui-layer-molv layui-layer-dialog innerMsg ' + id + (app.vm ? ' mlayer' : '') + ' ' + cla,
		title : t + (app.vm ? '<div class="layerbtn layer_close fa fa-arrow-left"></div>' : ''),
		anim : -1,
		isOutAnim : false,
		move : !app.vm,
		btn2 : !btn2 ? null : function(index)
		{
			if (endfun)
			{
				endfun(2);
				endfun = null;
			}
			layer.close(index);
		},
		yes : function(index)
		{
			if (btn2 && btn2.fun)
			{
				delete _showInnerMsg.m[id];
				btn2.fun();
			}
			if (endfun)
			{
				endfun(1);
				endfun = null;
			}
			layer.close(index);
		},
		end : function()
		{
			delete _showInnerMsg.m[id];
			if (endfun)
			{
				endfun(0);
				endfun = null;
			}
		},
	};
	if ($('.abstop').length > 0)
		p.zIndex = fullLayer_max_zindex2;
	if (!noBtn)
	{
		if (btntitle)
		{
			if (btn2)
				p.btn = [ btn2.title, btntitle ];
			else
				p.btn = btntitle;
		}
		else if (btntitle !== false)
		{
			p.btn = app.w('ok');
		}
	}
	if ((m.length > 2048 || (app.vm && m.length > 1024)) && !w)
	{
		w = $(window).width();
	}
	p.area = [ w + 'px', h ? (h + 'px') : 'auto' ];
	layerrindex = layer.alert('<div class="user-select" id="' + id + '">' + m + '</div>', p, function(index)
	{
		delete _showInnerMsg.m[id];
		if (btn2 && btn2.fun)
			btn2.fun();
		layer.close(index);
	});
	addLayerToList(layerrindex);
	_setInnerMsgTop(id);
	return layerrindex;
	function _setInnerMsgTop(id)
	{
		var wh = ($(window).height());
		var maxheight = wh - 97;
		$('.' + id + ' .layui-layer-content').css('max-height', maxheight + 'px');
		var h = $('.' + id).height();
		var top = $('.' + id).offset().top;
		var mintop = Math.max(0, (wh - h) / 2);
		if (mintop < top || top < 0)
		{
			$('.' + id).css('top', mintop + 'px');
		}
	}
}
function addLayerToList(layerIndex)
{
	if (!addLayerToList.list)
		addLayerToList.list = [];
	addLayerToList.list.push(layerIndex);
	if (addLayerToList.list.length > 16)
		layer.close(addLayerToList.list.shift());
}
/**
 * 加载动画
 * 
 * @param isclose
 * @returns
 */
function loading(isclose)
{
	if (isclose)
	{
		if (loading.index)
		{
			layer.close(loading.index);
			loading.index = 0;
		}
	}
	else
	{
		loading(true);
		loading.index = layer.open({
			type : 3,
			shade : [ 0.1, '#fff' ],
			time : 180000,
		});
	}
}
/**
 * 显示一段html代码
 * 
 * @param html
 * @returns
 */
function showHtml(html, noTrim, cassname)
{
	if (!html)
		html = '';
	html += ' ';
	var i1 = html.indexOf('<body>');
	var i2 = html.indexOf('</body>');
	if (i1 > 0 && i2 > 0)
		var body = html.substring(i1 + 6, i2);
	else
	{
		var body = html;
		if (body.length < 512)
		{
			showMsg(body);
			return;
		}
	}
	if (!cassname)
		cassname = '';
	var dd = body;
	var style = '<style>div.infoinfo{overflow:visible;word-break:break-all;}';
	if (!noTrim)
	{
		var tab = [ 'tr', 'td', 'div', 'table', 'strong', 'br', 'h1', 'h2', 'h3', 'h4' ];
		var dd = rm(dd, tab);
		var style = "div.infoinfo {font-size:14px;padding:12px;} div.infoinfo table{width:100%} div.infoinfo table td{border:1px solid #888;padding:6px}";
	}
	style += "</style>";
	dd = style + " <div class='user-select infoinfo " + cassname + "'>" + dd + "</div>";
	return layer.open({
		type : 1,
		title : 'Info',
		area : [ '100%', '100%' ],
		content : dd,
		closeBtn : 1,
		skin : ' realfulllayer',
		btn : [ 'close' ],
	}, function(index)
	{
		layer.close(index)
	});
	// ////////////////////////////////////
	function rm(dd, tab)
	{
		for (var i = 0; i < tab.length; i++)
		{
			var tabi = tab[i];
			dd = dd.replace(new RegExp('<' + tabi, 'g'), '00' + tabi + '00<' + tabi);
			dd = dd.replace(new RegExp('</' + tabi, 'g'), '00/' + tabi + '00</' + tabi);
		}
		dd = dd.replace(new RegExp('<\/?.+?>', 'g'), "");
		for (var i = 0; i < tab.length; i++)
		{
			var tabi = tab[i];
			dd = dd.replace(new RegExp('00' + tabi + '00', 'g'), '<' + tabi + '>');
			dd = dd.replace(new RegExp('00/' + tabi + '00', 'g'), '</' + tabi + '>');
		}
		return dd;
	}
}
/**
 * 格式化各种类型的数据
 * 
 * @param v
 * @param t
 * @paran jqobj 结果用于对它赋值
 * @returns
 */
function formatData(v, t, jqobj)
{
	if (v === null || v === undefined)
	{
		if (jqobj)
			jqobj.val(v);
		return '';
	}
	if (t == 'amount' || t == 'amount2')
		return formatAmount(v, t == 'amount2');
	else if (t == 'date')
		return getDateStr(v)
	else if (t == 'datetime')
		return getDateStr(v, true);
	else if (t == 'bool' || t == 'online' || t == 'bool2' || t == 'online2')
	{
		v = (v + ' ').trim().toLowerCase();
		if (v == '1' || v == 'yes' || v == 'true' || v == 'y')
			return t == 'online' || t == 'online2' ? app.w('onlineYes') : app.w('boolYes');
		else if (t == 'bool2' || t == 'online2')
			return '';
		else
			return t == 'online' || t == 'online2' ? app.w('onlineNo') : app.w('boolNo');
	}
	else if (t == 'password')
		return "******";
	else if (t == 'json' || t == 'jsoninline')
	{
		if (typeof v != 'object')
		{
			v = (v + ' ').trim();
			var h = v.substring(0, 1);
			if (h !== '{' && h !== '[')
				return v;
			try
			{
				var j = JSON.parse(v);
			}
			catch (err)
			{
				j = false;
			}
		}
		else
			j = v;
		if (!j)
			return v;
		else
			return arrToShowStr(j, 0, t == 'jsoninline');
	}
	else if (t == 'userid' || t == 'username')
	{
		var vi = strToInt(v);
		if (!vi)
			return '';
		var r = loginUser.setUserName(vi, null, t == 'username', jqobj);
		if (!jqobj)
		{
			if (r !== null)
				return '<font class="formatdata user_id_' + vi + '">' + r + '</font>';
			return '<font class="formatdata user_id_' + vi + '">' + vi + ' : ... </font>';
		}
		else
			return '';
	}
	else if (t == 'outerapiappid')
	{
		if (!v)
			return v;
		loginList.setOuterApiAppCaption(v, jqobj);
		if (!jqobj)
			return '<font class="formatdata outer_api_appid_' + v + '">' + v + ' : ... </font>';
		else
			return '';
	}
	else if (t == 'businessid' || t == 'businessname')
	{
		var vi = strToInt(v);
		if (!vi)
			return v;
		var r = loginList.setBusinessName(vi, t == 'businessname', jqobj);
		if (!jqobj)
		{
			if (r !== null)
				return '<font class="formatdata businessid_' + vi + '">' + r + '</font>';
			return '<font class="formatdata businessid_' + vi + '">' + vi + ' : ... </font>';
		}
		else
			return '';
	}
	else if (t == 'image')
	{
		if (v && (v + ' ').indexOf('<') >= 0)
			return v;
		return '<img src="' + v + '">';
	}
	else if (typeof t == 'function')
	{
		return t(v);
	}
	return v;
}
/**
 * 数组转化为显示字符串
 * 
 * @param j
 * @param pre
 * @param inline
 * @returns
 */
function arrToShowStr(j, pre, inline, fyservername)
{
	if (inline)
	{
		var re = '';
		for ( var k in j)
		{
			var v = j[k];
			if (typeof v == 'object')
				re += arrToShowStr(v, 0, true);
			else
				re += v + ' ';
		}
		re = (re + ' ').trim();
	}
	else
	{
		if (!pre)
			pre = 0;
		var re = '<div class="jsoncode">';
		for ( var k in j)
		{
			var v = j[k];
			re += '<p><span class="key">' + k + '</span> : ';
			if (typeof v == 'object')
				re += arrToShowStr(v, pre + 48, inline, fyservername);
			else
				re += v;
		}
		re += '</div>';
	}
	return re;
}
/**
 * 格式化html
 * 
 * @param str
 * @returns
 */
function html_encode(str)
{
	str = (str + ' ').trim();
	if (str.length == 0)
		return "";
	var s = str.replace(/&/g, "&amp;");
	s = s.replace(/</g, "&lt;");
	s = s.replace(/>/g, "&gt;");
	s = s.replace(/ /g, "&nbsp;");
	s = s.replace(/\'/g, "&#39;");
	s = s.replace(/\"/g, "&quot;");
	s = s.replace(/\n/g, "<br>");
	return s;
}
/**
 * 确认框
 * 
 * @param msg
 * @param fun
 * @returns
 */
function confirm(msg, fun, cancelfun, mustLogin, isfull, endfun, okcaption)
{
	var id = getRandId();
	var ml = '';
	var isG = login.haveAuth('login', 'G');
	if (mustLogin)
	{
		if (!login.isLogin())
		{
			errorMsg(app.w('login.msg.notLogin'));
			return;
		}
		ml += '<div>' + app.w('login.msg.areyousureforce');
		if (isG)
		{
			ml += '<p>' + app.w('userName') + ' ' + '<input readonly="true" id="na' + id + '" value="' + app.getUserName() + '">';
			var re = ' editabled="true" class="password" ';
			if (app.needWTPJp())
				re = ' readonly="true" editabled="true" class="password editabled" ';
			ml += '<p>' + app.w('passWord') + ' ' + '<input ' + re + ' type="password" id="pa' + id + '">';
		}
		ml += '<div style="margin:auto;position:relative;width:180px;height:180px;top:0;left:0;">' + left.getWeiXinLoginHtml('login', 'wx_login_box_c_confirm', function()
		{
			fun();
			layer.close(confirm.layerIndex);
		}, true, login.getUserId()) + '</div>';
		ml += '</div>';
	}
	msg = (msg + ' ').trim().replace(/\?/g, '？');
	if (msg.indexOf('？') < 0)
		msg += '？';
	msg += (msg ? '<p>' : '') + ml;
	if (!confirm.i)
		confirm.i = 1;
	var para = {
		type : 1,
		icon : 3,
		skin : 'layui-layer-molv layui-layer-dialog confirm',
		btn : [ okcaption ? okcaption : app.w('ok'), app.w('cancel') ],
		title : app.w('query'),
		end : function()
		{
			if (endfun && endfun() === false)
			{
				confirm(msg, fun, cancelfun, mustLogin, isfull, endfun);
			}
		},
		btn1 : function(index)
		{
			if (mustLogin)
			{
				if (!isG)
				{
					errorMsg(app.w('login.msg.pleaseUseWxScanAndSure'));
				}
				else
				{
					var na = ($('#na' + id)).val();
					var pa = ($('#pa' + id)).val();
					loginUser.login(na, pa, function()
					{
						fun();
						layer.close(index);
					});
				}
			}
			else
			{
				fun();
				layer.close(index);
			}
		},
		btn2 : function(index)
		{
			if (cancelfun)
			{
				if (false === cancelfun())
					return;
				cancelfun = null;
			}
			layer.close(index);
		},
		content : msg,
	};
	if ($('.abstop').length > 0)
		para.zIndex = fullLayer_max_zindex2;
	if (isfull)
	{
		var p = getFullArea(false);
		if (p)
		{
			para['offset'] = [ p.t, p.l ];
			para['area'] = [ p.w + 'px', p.h + 'px' ];
		}
	}
	confirm.layerIndex = layer.open(para);
	addLayerToList(confirm.layerIndex);
	return confirm.layerIndex;
}
/**
 * 弹出对话框，让用户输入地址，并返回格式化地址
 * 
 * @param backcun
 * @param value
 * @returns
 */
function getAddress(backcun, value, caption)
{
	if (!value)
		value = '';
	var val = (value + ' , , , , , , , ').split(',');
	var address = val[2].trim();
	var postcode = val[3];
	var dd = address.split(' ');
	val[2] = dd[0];
	val[3] = dd.length > 1 ? dd[1] : '';
	val[4] = dd.length > 2 ? dd[2] : '';
	val[5] = dd.length > 3 ? dd[3] : '';
	val[6] = postcode;
	var cap = [ app.w('name'), app.w('tel'), app.w('province'), app.w('city'), app.w('district'), app.w('address'), app.w('postcode') ];
	var para = [];
	for (var i = 0; i < cap.length; i++)
	{
		para.push([ i, cap[i], (val[i] + ' ').trim() ]);
	}
	(new formFun).getValues(caption ? caption : app.w('editAddress'), para, function(d)
	{
		var s = '';
		for ( var k in d)
		{
			d[k] = (d[k] + ' ').replace(/,/g, '，').replace(/\s/g, '');
			if (k == 3 || k == 4 || k == 5)
				s += ' ' + d[k];
			else
				s += (k == 0 ? '' : ',') + d[k];
		}
		backcun(s);
	})
}
/**
 * 选择快递
 */
function selectExpress(backfun, justMain, noDefault, istry)
{
	if (!window.outerapiApp)
	{
		if (istry)
			return errorMsg('no outerapi function');
		loadJs('servers/outerapi/app.js', function()
		{
			selectExpress(backfun, justMain, noDefault, true);
		});
		return;
	}
	outerapiApp.expressCodeList(function(d)
	{
		var arr = {};
		for (var i = 0; i < d.length; i++)
		{
			var k = d[i].wtpCode;
			if (justMain && k.indexOf('#') > 0)
				continue;
			if (k.toLowerCase() == '_none_')
			{
				if (justMain)
					continue;
				d[i].name = app.w('noneExpressCode');
			}
			if (k.toLowerCase() == '_default_')
			{
				if (noDefault)
					continue;
				d[i].name = app.w('defaultExpressCode');
			}
			arr[k] = k + ' : ' + d[i].name;
		}
		selectList(app.w('expressCode'), arr, function(v)
		{
			backfun(v);
		});
	});
}
/**
 * 从json字符串获取值
 * 
 * @param json
 * @param key
 * @returns
 */
function getValueFromJson(json, key)
{
	json = (json + ' ').trim();
	if (!json || !(json.indexOf('{') == 0 || json.indexOf('[') == 0))
		return undefined;
	try
	{
		var j = JSON.parse(json);
	}
	catch (err)
	{
		j = false;
	}
	if (!j)
		return undefined;
	else
		return j[key];
}
/**
 * 排序用
 * 
 * @param propertyName
 * @returns
 */
function compare(propertyName, isSheng)
{
	var k = isSheng ? 1 : -1;
	return function(object1, object2)
	{
		var value1 = object1[propertyName];
		var value2 = object2[propertyName];
		if (value2 < value1)
		{
			return k;
		}
		else if (value2 > value1)
		{
			return 0 - k;
		}
		else
		{
			return 0;
		}
	}
}
/**
 * 显示单张图片，支持手动放大
 */
function showImage(url, imageManagerName, correlationName, boxId, w, h, mw, mh, inList, toRightImg)
{
	boxId = boxId || '';
	if (typeof url == 'object' && $(url).hasClass('imgto'))
	{
		var k = $(url).parent().find('img.main');
		toRightImg = $(url).hasClass('imgtoright');
		if (k.length > 0 && k[0].src)
			showImage(k[0].src, imageManagerName, correlationName, boxId, 0, 0, 0, 0, 0, toRightImg);
		return;
	}
	if (toRightImg === true || toRightImg === false)
	{
		var u = url.replace(/\\/g, '/');
		var a = ('/' + u).split('/');
		var na = a[a.length - 1];
		var i = na.indexOf('.jpg');
		if (i > 0)
		{
			var ii = parseInt(na.substring(0, i));
			if (ii > 0)
			{
				i2 = ii + (toRightImg ? 1 : -1);
				if (i2 > 0)
				{
					newUrl = url.replace(ii + '.jpg', i2 + '.jpg');
					showImage(newUrl, imageManagerName, correlationName, boxId, 0, 0, 0, 0, true);
				}
			}
		}
		return;
	}
	if (typeof url == 'object')
		url = url.src;
	var layerIndex;
	if (!w || !h)
	{
		layerIndex = layer.msg('loading ...');
		mh = $(window).height();
		mw = $(window).width();
		var img = document.createElement("IMG");
		img.src = url;
		img.onload = function()
		{
			layer.close(layerIndex);
			if (showImage.index > 0)
			{
				layer.close(showImage.index);
				showImage.index = 0
			}
			showImage_Vm();
			showImage.tryi = 0;
			if (app.vm)
				showImage_Vm(url, imageManagerName, correlationName, boxId, img.width, img.height, mw, mh)
			else
				showImage(url, imageManagerName, correlationName, boxId, img.width, img.height, mw, mh);
		};
		img.onerror = function()
		{
			layer.close(layerIndex);
			if (!inList)
				layer.msg('show image failed');
		};
		return;
	}
	var mhmw = mh / mw;
	if (h / w > mhmw)
		var h0 = Math.min(mh, h);
	else
	{
		var w0 = Math.min(mw, w);
		var h0 = h * w0 / w;
	}
	if (h0 > mh - 48)
		var sk = 'fullimage';
	else
		sk = '';
	var img = "<img class='main' ondblclick='window.open(this.src)' style='max-width:" + mw + "px;max-height:" + mh + "px;' src='" + url + "' />";
	var more = '';
	if (imageManagerName && correlationName)
	{
		var wh = $(window).height();
		var tp = wh - (wh - h0) / 2;
		if (tp > wh - 33)
			tp = wh - 33;
		more = '<a class="more layer_close" style="bottom:4px" onclick="imagesImage.uploadImages(\'' + imageManagerName + '\',\'' + boxId + '\',\'' + correlationName + '\')">' + app.w('imageAndAppendixFile') + '</a>';
		more += '<img class="imgto imgtoleft" onclick="showImage(this,\'' + imageManagerName + '\',\'' + correlationName + '\',\'' + boxId + '\')" src="static/' + app.core + '/images/imgtoleft.png">';
		more += '<img class="imgto imgtoright" onclick="showImage(this,\'' + imageManagerName + '\',\'' + correlationName + '\',\'' + boxId + '\')" src="static/' + app.core + '/images/imgtoright.png">';
	}
	showImage.index = layer.open({
		type : 1,
		shade0 : false,
		title : false, // 不显示标题
		shadeClose : true,
		skin : 'showimage ' + sk,
		area : [ 'auto', 'auto' ],
		content : img + more,
	});
}
/**
 * 手机端显示图片，支持手势放大
 * 
 * @param url
 * @param iw
 *            图片元素尺寸
 * @param ih
 * @param ww
 *            窗口元素尺寸
 * @param wh
 * @returns
 */
function showImage_Vm(url, imageManagerName, correlationName, boxId, iw, ih, ww, wh)
{
	if (!url)
	{
		$('body .showImageVm').remove();
		showImage_Vm.s = null;
		showImage_Vm.m = null;
		showImage_Vm.r = null;
		showImage_Vm.getPos = null;
		return;
	}
	showImage_Vm();
	showImage_Vm.getPos = function(ms, xs, iw, ih, ww, wh, dx, dy)
	{
		if (ms > 0)
		{
			showImage_Vm.s = ms;
			var init = true;
		}
		else if (xs > 0)
		{
			showImage_Vm.s = (showImage_Vm.s || 1) * xs;
			var init = false;
		}
		var s = showImage_Vm.s;
		var r = showImage_Vm.r || {};
		if (iw > 0)
			r.iw = iw;
		if (ih > 0)
			r.ih = ih;
		if (ww > 0)
			r.ww = ww;
		if (wh > 0)
			r.wh = wh;
		r.w = r.iw / s;
		r.h = r.ih / s;
		if (init)
		{
			r.l = r.ww * 0.5 - r.w * 0.5;
			r.t = r.wh * 0.5 - r.h * 0.5;
		}
		if (dx > 0 || dx < 0)
			r.l += dx;
		if (dy > 0 || dy < 0)
			r.t += dy;
		// 调整边距top
		if (r.h <= r.wh)
			r.t = (r.wh - r.h) / 2;
		else if (r.t > 4)
			r.t = 4;
		else if (r.t < r.wh - r.h - 4)
			r.t = r.wh - r.h - 4;
		// 调整边距left
		if (r.w <= r.ww)
			r.l = (r.ww - r.w) / 2;
		else if (r.l > 4)
			r.l = 4;
		else if (r.l < r.ww - r.w - 4)
			r.l = r.ww - r.w - 4;
		var obj = $('.showImageVm img');
		if (obj.length > 0)
		{
			obj.css('top', r.t + 'px');
			obj.css('left', r.l + 'px');
			obj.width(r.w);
			obj.height(r.h);
			var tp = Math.max(6, r.t - 36);
			$('.showImageVm .fa-close').css('top', tp + 'px');
			var tl = Math.max(6, r.ww - r.l - r.w - 36);
			$('.showImageVm .fa-close').css('right', tl + 'px');
			var tp = r.t + r.h + 4;
			if (tp > $(window).height() - 33)
				tp = $(window).height() - 33;
			$('.showImageVm .more').css('top', tp + 'px');
		}
		showImage_Vm.r = r;
		return r;
	}
	var z = fullLayer_max_zindex + 500000;
	var ms;
	var rw = wh / ww;
	var ri = ih / iw;
	if (rw < ri)
		ms = ih / wh;
	else
		ms = iw / ww;
	if (ms < 1)
		ms = 1;
	var r = showImage_Vm.getPos(ms, 0, iw, ih, ww, wh);
	var tp = Math.max(6, r.t - 36);
	var tl = Math.max(6, ww - r.l - r.w - 36);
	var html = '<div class="showImageVm">';
	html += '<div onclick="showImage_Vm()" style="background:#000;z-index:' + z + ';top:0;left:0;width:100%;height:100%;position:fixed;opacity:0.5;"></div>';
	html += '<img src="' + url + '" style="top:' + r.t + 'px;left:' + r.l + 'px;width:' + r.w + 'px;height:' + r.h + 'px;display:block;z-index:' + (z + 1) + ';position:fixed;" >';
	html += '<i onclick="showImage_Vm()" style="top:' + tp + 'px;right:' + tl + 'px;width:34px;text-align:center;border-radius:50%;border:4px solid white;padding:6px;position:fixed;z-index:' + (z + 2) + ';background:red;color:white" class="fa white fa-close"></i>';
	if (imageManagerName && correlationName)
	{
		var tp = r.t + r.h + 4;
		if (tp > $(window).height() - 33)
			tp = $(window).height() - 33;
		html += '<a class="more" style="z-index:' + (z + 2) + ';top:' + tp + 'px" onclick="showImage_Vm();imagesImage.uploadImages(\'' + imageManagerName + '\',\'' + boxId + '\',\'' + correlationName + '\')">' + app.w('imageManage') + '</a>';
	}
	html += '</div>';
	$('body').append(html);
	showImage_Vm.url = url;
	// 添加事件
	if (!showImage_Vm.e)
	{
		showImage_Vm.e = true;
		$('body').on('click', "div.showImageVm img", function(e)
		{
			if (showImage_Vm.click1)
			{
				var x = showImage_Vm.m.clientX;
				var mx = $(window).width();
				if (x > mx / 2)
					showImage(showImage_Vm.url, imageManagerName, correlationName, boxId, 0, 0, 0, 0, 0, true)
				else
					showImage(showImage_Vm.url, imageManagerName, correlationName, boxId, 0, 0, 0, 0, 0, false)
			}
		});
		$('body').on('touchstart', "div.showImageVm img", function(e)
		{
			showImage_Vm.click1 = true;
			if (e.originalEvent && e.originalEvent.touches)
			{
				if (!showImage_Vm.m)
					showImage_Vm.m = {};
				showImage_Vm.m.clientX = e.originalEvent.touches[0].clientX;
				showImage_Vm.m.x = e.originalEvent.touches[0].screenX;
				showImage_Vm.m.y = e.originalEvent.touches[0].screenY;
				if (e.originalEvent.touches.length > 1)
				{
					showImage_Vm.click1 = false;
					showImage_Vm.m.x2 = e.originalEvent.touches[1].screenX;
					showImage_Vm.m.y2 = e.originalEvent.touches[1].screenY;
					showImage_Vm.m.n = 2;
				}
				else
				{
					showImage_Vm.m.n = 1;
				}
			}
		});
		$('body').on('touchmove', "div.showImageVm img", function(e)
		{
			showImage_Vm.click1 = false;
			if (!showImage_Vm.m)
				showImage_Vm.m = {};
			var x = e.originalEvent.touches[0].screenX;
			var y = e.originalEvent.touches[0].screenY;
			if (e.originalEvent.touches.length > 1)
			{
				var x2 = e.originalEvent.touches[1].screenX;
				var y2 = e.originalEvent.touches[1].screenY;
				var n = 2;
			}
			else
			{
				var n = 1;
			}
			var oldx = showImage_Vm.m.x;
			var oldx2 = showImage_Vm.m.x2;
			var oldy = showImage_Vm.m.y;
			var oldy2 = showImage_Vm.m.y2;
			var xs = 1;
			if (showImage_Vm.m.n == 1 || n == 1)
			{
				if (showImage_Vm.m.n != n)
					return;
				var dx = x - oldx;
				var dy = y - oldy;
			}
			else
			{
				var dx = ((x - oldx) + (x2 - oldx2)) / 2;
				var dy = ((y - oldy) + (y2 - oldy2)) / 2;
				var s1 = Math.sqrt((oldx - oldx2) * (oldx - oldx2) + (oldy - oldy2) * (oldy - oldy2));
				var s2 = Math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2));
				if (s1 > 0 && s2 > 0)
				{
					xs = s1 / s2;
					if (showImage_Vm.s < 0.1 && xs < 1)
						xs = 1;
					var xx = (x + x2 + oldx + oldx2) / 4 - showImage_Vm.r.l;
					var yy = (y + y2 + oldy + oldy2) / 4 - showImage_Vm.r.t;
					var xx = x - showImage_Vm.r.l;
					var yy = y - showImage_Vm.r.t;
					dx -= (xx * (1 - xs));
					dy -= (yy * (1 - xs));
				}
			}
			if (showImage_Vm.getPos(0, xs, 0, 0, 0, 0, dx, dy))
			{
				showImage_Vm.m.x = x;
				showImage_Vm.m.y = y;
				showImage_Vm.m.n = n;
				if (n > 1)
				{
					showImage_Vm.m.x2 = x2;
					showImage_Vm.m.y2 = y2;
				}
			}
		});
	}
}
/**
 * 导出文件
 */
function outputFile(method, para, templete, edit, del, businessId, timeout, requestBackFun)
{
	if (!businessId)
	{
		app.selectBusiness(function(businessId)
		{
			outputFile(method, para, templete, edit, del, businessId)
		});
		return;
	}
	if (method)
		outputFile.method = method;
	if (para)
		outputFile.para = para;
	if (templete)
		outputFile.templete = templete;
	if (del)
	{
		confirm(app.w('login.msg.areYouSuredeleteTtemplete') + '?', function()
		{
			ajax.request('wtp.login.tools.GetExcelTemplate', {
				name : outputFile.templete,
				'delete' : 'yes',
				businessId : businessId,
			}, function(d, ad)
			{
				$('#uploadeFileName11').html(app.w('login.msg.TemplateFileHaveChange'));
			});
		});
		return;
	}
	if (edit)
	{
		(new inputFun).setExcelTemplate(function()
		{
			$('#uploadeFileName11').html(app.w('login.msg.TemplateFileHaveChange'));
		}, outputFile.templete, '');
		return;
	}
	if (!method)
		return;
	para['templete'] = {
		inputtype : 'hidden',
		value : templete,
	};
	if (!para['caption'])
	{
		para['caption'] = {
			inputtype : '',
			value : '',
			caption : app.w('memo'),
		};
	}
	var bp = {};
	for ( var k in para)
	{
		if (para[k].value)
			bp[k] = para[k].value;
	}
	var form = new formFun({
		'container' : '',
		'method' : method,
		'showmemo' : true,
		'classname' : 'noborder',
		'submitTitle' : app.w('doOutputFile'),
		'savemark' : 'outputFile' + method,
		'timeout' : timeout,
		'loadDataFun' : function(backfun)
		{
			backfun(bp);
		},
		preDealDataFun : function(data)
		{
			$('#uploadeFileName11').html(app.w('login.msg.outputing') + ' ...');
			outputFile.data = data;
			return data;
		},
		requestBackFun : function(d, ad)
		{
			if (ad['filename'])
			{
				var url = app.getServerUrl('login').replace('index.php', '');
				url += 'output/excel/' + ad['filename'];
				$('#uploadeFileName11').html('<a class="fa fa-check allowrightmenu" target="_blank" href="' + url + '"> &nbsp; ' + app.w('login.msg.rightSave') + '</a>');
			}
			else
			{
				errorMsg('No field "filename" in output data,check the serever program');
			}
			if (requestBackFun)
				requestBackFun(outputFile.data);
		},
		'paras' : para
	});
	var html = form.html;
	html += '<p style="margin:0 32px 0 32px"><span id="uploadeFileName11" class="red">' + app.w('login.msg.pleaseClickOutput');
	if (login.haveAuth('login', 'M'))
	{
		html += ' &nbsp;  &nbsp;  &nbsp; <a onclick="outputFile(null,null,null,true,false,' + businessId + ')" >' + app.w('editTemplete') + '</a>';
		html += ' &nbsp;  &nbsp;  &nbsp;  <a onclick="outputFile(null,null,null,false,true,' + businessId + ')" >' + app.w('resetTemplete') + '</a>';
	}
	html += '</span>';
	if (outputFile.layerIndex > 0)
	{
		var i = outputFile.layerIndex;
		setTimeout(function()
		{
			layer.close(i);
		}, 333);
	}
	outputFile.layerIndex = showFullLayer(app.w('outputFile'), html);
	form.layerIndex = outputFile.layerIndex;
	return form;
}
/**
 * 连接蓝牙
 * 
 * @param backfun
 * @param type //
 *            printer weight 暂时连接为称
 * @param tryQueryTimes
 * @returns
 */
function bleConn(backfun, type, tryQueryTimes)
{
	var andr = window.toAndroidApp;
	if (!andr)
	{
		backfun(false, app.w('login.msg.notInAndroidApp'));
		return;
	}
	if (!tryQueryTimes)
	{
		if (bleConn.tryQueryTimes === 0 || bleConn.tryQueryTimes > 0)
		{
			// layer.msg('bleConning ...');
			return;
		}
		andr.bleConn(type);
		tryQueryTimes = 0;
	}
	bleConn.tryQueryTimes = tryQueryTimes;
	// 连接10秒超时,循环探索蓝牙连接情况
	setTimeout(function()
	{
		var isConn = !!bleIsOnline();
		if (!isConn && tryQueryTimes < 20)
		{
			bleConn(backfun, type, tryQueryTimes + 1);
		}
		else
		{
			if (!isConn && tryQueryTimes < 40)
			{
				showMsg('', app.w('login.msg.BLEConnIng'), 0, function()
				{
					bleConn(backfun, type, 40);
				});
				return;
			}
			bleConn.tryQueryTimes = null;
			backfun(isConn, isConn ? app.w('login.msg.BLEConnOk') : app.w('login.msg.BleConnFailed'));
		}
	}, 500);
}
function bleIsOnline()
{
	var andr = window.toAndroidApp;
	if (!andr)
		return null;
	var re = andr.bleIsOnline();
	return re == 'yes';
}
// 断开连接蓝牙
function bleDisConn(backfun)
{
	var andr = window.toAndroidApp;
	if (!andr)
	{
		backfun(false, app.w('login.msg.notInAndroidApp'));
		return;
	}
	andr.bleDisConn();
	setTimeout(function()
	{
		var isConn = !!bleIsOnline();
		backfun(!isConn, isConn ? app.w('login.msg.BleDisconnFailed') : app.w('login.msg.BleDisconnOk'));
	}, 333);
}
function selectIcon(backfun, icons, c)
{
	if (backfun)
		selectIcon.backfun = backfun;
	if (icons)
	{
		var s = '';
		for (var i = 0; i < icons.length; i++)
		{
			if ((i % 20) == 0)
			{
				s += '<p style="text-align:center">';
			}
			s += '<a onclick="selectIcon(0,0,\'' + icons[i] + '\')" class="fa fa-' + icons[i] + '"></a> &nbsp;  &nbsp; ';
		}
		selectIcon.layerIndex = showMsg(s);
		return;
	}
	else if (c)
	{
		if (selectIcon.backfun)
		{
			selectIcon.backfun(c);
			selectIcon.backfun = null;
			layer.close(selectIcon.layerIndex);
		}
		return;
	}
	if (typeof _getIcons != 'function')
	{
		loadJs(app.core + '/js/public/icons.js', function()
		{
			icons = _getIcons();
			if (icons)
				selectIcon(null, icons);
		});
	}
	else
	{
		icons = _getIcons();
		if (icons)
			selectIcon(null, icons);
	}
}
// //////////////////////
if (!window.toAndroidApp && 0)
{
	// 以下是测试
	var bleOnline = 0;
	window.toAndroidApp = {
		bleIsOnline : function()
		{
			return bleOnline > 0 ? 'yes' : 'no';
		},
		bleConn : function()
		{
			bleOnline++;
		},
		bleDisConn : function()
		{
			bleOnline = 0;
		},
		play : function()
		{
		},
		getBLEData : function()
		{
			if (ware.v)
				return ware.v;
			return "0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;0.12;";
		},
		tryGetFinger : function()
		{
		},
		sendPrintData : function()
		{
		},
		getPrintId : function()
		{
			return '-printed';
		},
	}
}
